package net.netca.testwebservice.bo;

import java.io.File;

import org.dom4j.Document;
import org.dom4j.io.SAXReader;

public class XMLConfig {
	private static String url;

	public String getUrl() {
		return url;
	}

	private void setUrl(String url) {
		this.url = url;
	}
	
	private static XMLConfig instance = null;   
    
	
	private XMLConfig()
	{}
	
	protected XMLConfig(String path) {   
	      // Exists only to defeat instantiation.  

		
		
		File dbxmlFile=new File(path);
		SAXReader reader=new SAXReader();
		try{
			Document document=reader.read(dbxmlFile);
			this.setUrl(document.selectSingleNode("/root/url").getText());
			
		}catch (Exception e) {
			e.printStackTrace();
		}finally{

		}
	}   
	public static void init(String path) {   
	   if(instance == null) {   
	      instance = new XMLConfig(path);   
	   }   
	}   
	
	public static XMLConfig getInstance() {   
		   return instance;   
		}  
}
